package com.itjob.scott.servlet;


import java.io.IOException;
import java.util.Date;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.itjob.scott.entity.UserEntity;


/**
 * 处理登录
 * @author 腾田田
 * com.itjob.scott.servlet.LoginServlet.java
 * 2016-4-12
 */
public class LoginServlet extends HttpServlet {
	private static final long serialVersionUID = -3699279506143210330L;
	
	@Override
	protected void service(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		String username = request.getParameter("username");
		boolean gender = "1".equals(request.getParameter("gender"));
		Date lastLoginTime   = new Date();
		UserEntity user =new UserEntity();
		user.setUsername(username);
		user.setGender(gender);
		user.setLastLoginTime(lastLoginTime);
		
		//不验证密码 恒成功
		request.getSession().setAttribute("user", user);
		response.sendRedirect("chat.jsp");
		
		
	}

}
